package com.cn.aam.checaiduo.ui.more;

import android.content.Intent;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.cn.aam.checaiduo.AppData;
import com.cn.aam.checaiduo.Const;
import com.cn.aam.checaiduo.R;
import com.cn.aam.checaiduo.backend.RetrofitHome;
import com.cn.aam.checaiduo.backend.observer.OnRequestListener;
import com.cn.aam.checaiduo.backend.rx.RxSchedulers;
import com.cn.aam.checaiduo.base.BaseActivity;
import com.cn.aam.checaiduo.base.ToolBarManager;
import com.cn.aam.checaiduo.bean.me.PointB;
import com.cn.aam.checaiduo.ui.arouter.UIRouter;
import com.cn.aam.checaiduo.ui.arouter.section.RouterMore;
import com.cn.aam.checaiduo.utils.MyViewsUtils;

import butterknife.BindView;


@Route(path = UIRouter.MORE.TASK_CENTER, name = "任务中心")
public class TaskCenterActivity extends BaseActivity {


    @BindView(R.id.tv_task_exp)
    TextView tvTaskExp;


    @Override
    protected int layoutId() {
        return R.layout.activity_task_center;
    }

    @Override
    protected void onGenerate() {
        MyViewsUtils.hideAllViews(tvTaskExp);

        RetrofitHome.getInstance()
                .getInternalApi()
                .getPoint(AppData.getToken())
                .compose(RxSchedulers.<PointB>toMain())
                .subscribe(new OnRequestListener<PointB>(this) {
                    @Override
                    public void onNext(PointB value) {
                        super.onNext(value);
                        if (value.getCode() == Const.REQUEST_SUCCESS) {
                            tvTaskExp.setText(value.getPoint());
                            MyViewsUtils.showAllViews(tvTaskExp);
                        }

                    }
                });
    }

    @Override
    protected void initView() {
        ToolBarManager.with(this, WMContent)
                .setTitle("任务中心")
                .setBackgroundColor(R.color.colorPrimary)
                .setNavigationIcon(R.drawable.ic_nav_arrow_white);
    }

}
